﻿@{string dialogId = "addTaskDialog";}

<style>
    #@dialogId input[type=text] {width: 100%}
    #@dialogId textarea {width: 100%; height: 70px;}
</style>
<script type="text/javascript">
    $(function () {
        $("#@dialogId").dialog({ height: 240, modal: true, autoOpen: false });
    });

    function openDialog() {
        $("#@dialogId").dialog('open');
    }

    function closeDialog() {
        $("#@dialogId").dialog('close');
        location.reload(true);
    }

    function failed(result, Data) {
        alert(Data);
    }
    </script>
    <div id="@dialogId" title="Добавить задачу" style="display: none">
        @using(Ajax.BeginForm("Add", "Tasks", new AjaxOptions{OnSuccess = "closeDialog", OnFailure = "failed", HttpMethod = "Post"}))
        {
            <div>Название:</div>
            <div><input type="text" name="Title"/></div>
            <div>Описание:</div>
            <div><textarea name="Description"></textarea></div>
            <div><input type="submit" value="Добавить"/></div>
        }
    </div>

